#include "DriverManager.h"
#include <iostream>

#include "DriverModule/ConcreteDriver/Forker.h"
#include "DriverModule/ConcreteDriver/Motor.h"
#include "DriverModule/ConcreteDriver/IO.h"

bool DriverManager::Init()
{
    // 注册各个模拟的硬件对象
    RegisterDriver<Forker>("Forker");
    RegisterDriver<Motor>("motor1");
    RegisterDriver<Motor>("motor2");
    RegisterDriver<IO>("charge");
    // register other drivers ...


    // 每个驱动进行init()调用...
    bool ret = true;
    for (auto& item : m_drivers)
    {
        ret = item.second->Init();
        if (!ret)
        {
            break;
        }
    }

    if (ret)
    {
        std::cout << "DriverManager::Init() success" << std::endl;
    }
    else
    {
        std::cout << "DriverManager::Init() error" << std::endl;
    }
    return ret;
}
